package com.cvpoc.service.impl;

import java.util.List;

import com.cvpoc.dto.CompetenceDTO;
import com.cvpoc.exception.BusinessException;
import com.cvpoc.hibernate.dao.CompetenceDao;
import com.cvpoc.service.CompetenceService;

public class CompetenceServiceImpl implements CompetenceService {

	private CompetenceDao competenceDao;

	public void setCompetenceDao(CompetenceDao competenceDao) {
		this.competenceDao = competenceDao;
	}

	@Override
	public List<CompetenceDTO> rechercherAllCompetence()
			throws BusinessException {
		List<CompetenceDTO> competenceDTOs =  competenceDao.findAllCompetence();
		if(competenceDTOs.isEmpty()){
			throw new BusinessException("Aucune compétence présent en base");
		}
		return competenceDTOs;
	}

	@Override
	public void createCompetence(CompetenceDTO competenceDTO)
			throws BusinessException {
		competenceDao.createCompetence(competenceDTO);
	}

}
